package yf.mall.dao;

import com.yf.dao.BaseDao;
import org.apache.ibatis.annotations.Select;
import yf.mall.entity.MallStoreEntity;
import yf.mall.vo.MallStoreVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import yf.mall.vo.web.MallGoodsVO;

import java.util.List;

/**
 * 产品库存Dao
 *
 *
 *
 * @date Sun Sep 29 09:50:50 CST 2019
 */
@Mapper
public interface MallStoreDao extends BaseDao<MallStoreEntity> {


//    List<MallStoreVo> queryListVo(MallStoreVo mallStoreVo);
//
//    MallStoreVo getVo(Long id);

    List<MallStoreVo> findByUserId(Long userId);

    MallStoreEntity findByUserIdAndGoodsId(@Param("userId") Long userId, @Param("goodsId") Long goodsId);

    void increase(@Param("userId") Long userId, @Param("goodsId") Long goodsId, @Param("quantity") Integer quantity);

    void decrease(@Param("userId") Long userId, @Param("goodsId") Long goodsId, @Param("quantity") Integer quantity);


    @Select("select goods.id,goods.mid_img,goods.name,store.quantity as stock,store.sku_name from mall_goods as goods left join mall_store as store on store.goods_id = goods.id where store.user_id = #{userId} and store.quantity > 0")
    List<MallGoodsVO> findVOByUserId(Long userId);
}
